package cc.dd.marketing.common;

import lombok.Getter;

/**
 * 优惠券状态枚举
 *
 * @author dongsufeng
 * @date 2022/9/9 2:23 PM
 */
@Getter
public enum CouponStatusEnum {
    UNUSED(1, "未使用", "2"),
    USED(3, "已使用", "2"),
    FROZEN(2, "已冻结", "1"),
    EXPIRED(4, "已过期", "1,2");

    private Integer code;
    private String desc;
    private String preState;

    CouponStatusEnum(Integer code, String desc, String preState) {
        this.code = code;
        this.desc = desc;
        this.preState = preState;
    }

    public static CouponStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (CouponStatusEnum statusEnum : values()) {
            if (statusEnum.getCode() == code) {
                return statusEnum;
            }
        }
        return null;
    }

}
